<template>
  <!-- 建设验收审核 -->
  <div>
    <!-- 搜索 -->
    <TopFilter
      :list="topFilterInit"
      :cols="3"
      labelWidth="100"
      @filterChange="changeHandle"
      @onCollapse="collapseHandle"
    ></TopFilter>
    <!-- table -->
    <FilterTable
      ref="table"
      :columns="columns"
      :isSelectColumn="isSelectColumn"
      :fetchapi="fetchParams"
      :params="flterValue"
      :datakey="'records'"
      :onColumnsChange="columns => this.columns = columns"
    >
      <template slot="controls">
        <el-button size="small" type="primary" icon="el-icon-download" >下载</el-button>
      </template>
    </FilterTable>
        <!-- 经销商弹窗 -->
  <BaseDialog title="经销商查询" :visible.sync="visibleDealer"
      width="1000px"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}" >
      <dealer-madal  ref="addDialog" @close="closeDealer" />
   </BaseDialog>
    <Drawer
      :visible.sync="visibleDrawer"
      title="经销商入网信息"
      :width="920"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
       >
      <info-modal v-model="initData" @close="infoClose" />
    </Drawer>
  </div>
</template>
<script>
import dealerMadal from '../../../customerManage/clue/areaBossPush/dealerMadal'
import infoModal from '../review/info';
import { dictionary } from '@/utils/dictMixin';
export default {
  name:'inquire',
  mixins: [dictionary],
  components: {
    infoModal,dealerMadal
  },
  data() {
    return {
      visibleDealer:false,
      isSelectColumn: false,
      visibleDrawer: false,
      initData: {},
      topFilterInit: this.topFilterInitFun(),
      flterValue: {}, //参数
      columns: this.creatHeader(),
      fetchParams: null //ipa 接口
    };
  },
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  methods: {
    //搜索数据
    topFilterInitFun() {
      return [
        { type: 'INPUT',  label: '经销商', fieldName: 'field1',  placeholder: '请选择', initialValue: '',
             unitRender: () => {
                    return <el-button slot="append" icon="el-icon-search" onClick={() =>this.dealerHandle()}></el-button>
              },
            },
        { type: 'SELECT', label: '经销商类型', fieldName: 'field2', placeholder: '请选择', initialValue: '', itemList: this.createDictList('1008') },
        { type: 'RANGE_DATE',  label: '创建日期',  fieldName: 'field22',  valueFormat: 'yyyy-MM-dd',   initialValue: '', placeholder: '请选择' },
        { type: 'SELECT', label: '事业部', fieldName: 'field3', placeholder: '请选择', initialValue: '', itemList: this.createDictList('1008') },
        { type: 'SELECT', label: '经销商级别', fieldName: 'field31', placeholder: '请选择', initialValue: '', itemList: this.createDictList('1008') },
        { type: 'SELECT', label: '建设状态', fieldName: 'JIanshe', placeholder: '请输入', initialValue: '', itemList: this.createDictList('1008')},
        { type: 'SELECT', label: '省份', fieldName: 'field4', placeholder: '请输入', initialValue: '', itemList: this.createDictList('1008')},
        { type: 'SELECT', label: '城市', fieldName: 'field5', placeholder: '请选择', initialValue: '', itemList: this.createDictList('1008') },
        { type: 'SELECT', label: '县区', fieldName: 'field6', placeholder: '请选择', initialValue: '', itemList: this.createDictList('1008') },
        { type: 'SELECT', label: '审批状态', fieldName: 'shenpi', placeholder: '请选择', initialValue: '', itemList: this.createDictList('1008') }
     ];
    },
    //搜索获取数据
    changeHandle(val) {
      this.flterValue = val;
      console.log(val);
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 100,
          fixed: 'left',
          render: (props, h) => {
            return (
              <div>
                <el-button size="mini" type="text" onClick={() => this.detailHandle(props.row,'info')}>
                  明细
                </el-button>
              </div>
            );
          }
        },
        { title: '公司全称', dataIndex: 'field2', sorter: true },
        { title: '临时代码', dataIndex: 'field3', sorter: true },
        { title: '经销商简称', dataIndex: 'field4', sorter: true },
        { title: '经销商类型', dataIndex: 'field5', sorter: true,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.basedataRelateId, '1611')}</span>;
          } },
        { title: '经销商级别', dataIndex: 'field6', sorter: true },
        { title: '建设类型', dataIndex: 'field7', sorter: true },
        { title: '建设节点', dataIndex: 'field8',  sorter: true  },
        { title: '审批状态', dataIndex: 'field80',  sorter: true  },
        { title: '展厅级别', dataIndex: 'field9', sorter: true },
        { title: '售后级别', dataIndex: 'field10', sorter: true },
        { title: '事业部', dataIndex: 'field11', sorter: true },
        { title: '办事处', dataIndex: 'field12', sorter: true },
        { title: '省份', dataIndex: 'field13', sorter: true },
        { title: '城市', dataIndex: 'field14', sorter: true },
        { title: '县区', dataIndex: 'field15', sorter: true },
        { title: '建设地址', dataIndex: 'field16', sorter: true },
        { title: '店端主要联系人', dataIndex: 'field17', sorter: true },
        { title: '联系人电话', dataIndex: 'field18', sorter: true },
        { title: '厂家负责人', dataIndex: 'field19', sorter: true },
        { title: '负责人电话', dataIndex: 'field20', sorter: true },
        { title: '项目设计师', dataIndex: 'field21', sorter: true },
        { title: '设计师电话', dataIndex: 'field22', sorter: true }
      ];
    },
     // 经销商打开窗口 -传数据
      dealerHandle(){
        this.visibleDealer=true
      },
      // 经销商关闭窗口 -返回数据
      closeDealer(data){
        //返回数据逻辑自己写
        this.topFilterInit[0].initialValue='选择经销商'
        this.visibleDealer=data.visible //关闭弹窗
    },
    //详情
    detailHandle(row,type) {
      //逻辑自己写
      this.initData =  {
        type: 'add',   //add/edit/show
        id:1001
      }; //行id
      this.visibleDrawer = true;
    },
    //关闭详情
    infoClose() {
      this.visibleDrawer = false;
      if (type === 'refresh') {
        // 重新加载
        this.fetchParams = { ...this.fetchParams };
      }
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    }
  }
};
</script>

<style lang="less" scoped>
</style>
